<%@page import="custom.User"%>
<%@page import="custom.Message"%>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>header</title>
</head>

<body>

	<%
	if (session.getAttribute("user") == null) {
		RequestDispatcher dispatch = request
				.getRequestDispatcher("/login.jsp");
		dispatch.forward(request, response);
	} else {
	%>
	
	<%if (session.getAttribute("alert") != null) {
			String str = (String) session.getAttribute("alert");%>
		<script type="text/javascript">
			alert('<%=str%>');
		</script>
	<%
		session.removeAttribute("alert");
	}%>
	
	
	<center>
		<div style="width: 800px; background-color:rgb(200, 220, 200); ;  margin-bottom: 10px;">
			
			<div style="float: left; width: 10%;">
				<input type="button" name="homeButton"
					style="border: 0px; BACKGROUND-IMAGE: url('images/HomeButton.png'); HEIGHT: 24px; WIDTH: 30px" ONCLICK="window.location.href='home.jsp'" />
			</div>

			<div style="float: left; width: 45%;">
				<form action="SearchServlet" method="post">
					USER 
					<input type="hidden" name="userOrQuiz" value="user" />
					<input type="text" name="word" /> 
					<input type="submit" value="" style="border: 0px; BACKGROUND-IMAGE: url('images/SearchButton.png'); HEIGHT: 20px; WIDTH: 20px" />
				</form>
			</div>

			<div style="float: left; width: 45%; margin-bottom: 10px;">
				<form action="SearchServlet" method="post">
					QUIZ
					<input type="hidden" name="userOrQuiz" value="quiz" />
					<input type="text" name="word" /> 
					<input type="submit" value="" style="border: 0px; BACKGROUND-IMAGE: url('images/SearchButton.png'); HEIGHT: 20px; WIDTH: 20px" />
				</form>
			</div>
			
			<hr>

			<div style="display: inline; ">
				<%
					if (((User) session.getAttribute("user")).areYouAdmin()) {
				%>
						<input type="button" name="All Users" value="All Users"
						ONCLICK="window.location.href='allUsers.jsp'" />
				<%
					}
				%>
				
				<input type="button" value="All Quizzes"
					ONCLICK="window.location.href='allQuizzes.jsp'" />
					
				<input type="button" value="Create a Quiz"
					ONCLICK="window.location.href='newQuiz.jsp'" />
					
				<input type="button" value="Messages <%if (Message.hasNewMessage(((User) session.getAttribute("user")).getId())) {out.print("(new)");}%>"
						ONCLICK="window.location.href='messages.jsp'" />
					
				<input type="button" value="my Profile"
					ONCLICK="window.location.href='profile.jsp?name=<%=((User) session.getAttribute("user")).getName()%>'" />
					
				<input type="button" value="log out" 
					ONCLICK="window.location.href='LogoutServlet'" />
					
			</div>
		</div>
	</center>
	<%
		}
	%>
</body>
</html>

